function [] = SNRfreqplot(static,pitch,yaw,Fs,stimulusFreq,excludeTrial)
%SNRFERQPLOT 此处显示有关此函数的摘要
%staic/yaw/pitch：SSVEP数据，第一个维度为session，第二个维度为stimulus，第三个维度为trial，第四个维度为channel，第五个维度为samplepoints
%Fs：采样率
%stimulusFreq：刺激频率，e.g.[6.67 12.0 10.0 8.57]
%excludeTrial: 移除的trial，每一行表示一个trial，格式为[stimulus condition session trial]

for condition = 1:3
    switch condition
        case 1
            data = static;
        case 2
            data = yaw;
        case 3
            data = pitch;
    end
    condition_text = {'Static','Yaw','Pitch'};
    for stimulus = 1:4
        figure;
        nsnr_session = [];
        for session = 1:size(data,1)
            avl_trial_index = 0;
            nsnr_trial = [];
            for trial = 1:size(data,3)
                %移除错误数据
                avl_trial_flag = 1;
                for i = 1:size(excludeTrial,1)
                    excludei = excludeTrial(i,:);
                    if(all([stimulus condition session trial] == excludei))
                        avl_trial_flag = 0;
                        break;
                    end
                end
                if(~avl_trial_flag)
                    continue;
                end
                avl_trial_index = avl_trial_index + 1;
                epoch = data(session,stimulus,trial,:,:);
                epoch = reshape(epoch,size(data,4),size(data,5));
                [fftepoch,f] = fast_fourier_transform(epoch',Fs);
                for freq = 1:length(f)
                    if(freq < 15 || freq > (length(f) -15))
                        nsnr_trial(avl_trial_index,freq) = 0;
                        continue;
                    end
                    nsnr_trial(avl_trial_index,freq) = narrow_signal_noise_ratio(fftepoch, f(freq), Fs);
                end
            end
            nsnr_session(session,:) = mean(nsnr_trial,1);
        end
        meansnr = mean(nsnr_session,1);
        meansnr = reshape(meansnr,1,[]);
        plot(f,meansnr,'linewidth',2);
        hold on;
        xlabel('Frequency [Hz]');
        ylabel('Signal Noise Ratio [dB]');
        axis([3 30 -10 30]);
        title(['SNR spectra of SSVEPs in repose to the ',num2str(stimulusFreq(stimulus)),' Hz stimuli ', condition_text{condition}]);
        set(gca, 'linewidth', 2, 'fontsize', 20, 'fontname', 'times');
    end
end
end

